
/*
* @version: 1.0
* @Author: zhanggq
* @Date: 2022-4-27
* @LastEditors: zhanggq
* @LastEditTime: 2022-04-27
* @Description: 文件实现描述
*/



#include <memory>

#include "IModule.h"
#include "../include/dlt645_main.h"



char *get_module_name(){
    return (char *)"2";// "DL/T645";
}
/**
* @brief 处理DL/T645业务逻辑
*
* @param pcm           - 配置信息
* @param psp           - 串口代理(同步处理串口请求与接收)
* @param pmm           - mqtt通信对象指针
* @param ptask          - 设备包含的请求信息请求信息
* @return int
*/
int run(std::shared_ptr<CConfigManager> pcm, 
    std::shared_ptr<IChannel> channel_ptr,
        std::shared_ptr<CMosquittoManager> pmm, 
        IModule &im,
        std::shared_ptr<TASK_PARAMS> ptask){
    return CDlt645MessageManager::getInstance().run(pcm, channel_ptr.get(), pmm, im, ptask.get());
}

int packet_parent_frame(std::shared_ptr<CConfigManager> cm, std::shared_ptr<TERMINAL_DEVICE> pdev, uint8_t *data, int &len){
    return CDlt645MessageManager::getInstance().packet_parent_frame(cm, pdev, data, len);
}
int parse_parent_frame(std::shared_ptr<CConfigManager> cm, uint8_t *data, int &len){
    uint8_t modbus_rsp[256] = {0};
    int rsplen = 0;
    if (0 < CDlt645MessageManager::getInstance().get_embeded_modbusdata(data,len,modbus_rsp,rsplen))
    {
        memcpy(data, modbus_rsp, rsplen);
        len = rsplen;
    }
    return len;
}